﻿#ifndef SERIALCOM_H
#define SERIALCOM_H

#include <QObject>
#include <QSerialPort>
#include "ComBase.h"

class SerialCom : public ComBase
{
    Q_OBJECT
public:
    explicit SerialCom(QObject *parent = nullptr);
    ~SerialCom(){}

public slots:
    virtual void onInit() override;
    virtual void onQuit() override;

protected:
    virtual void writeData(const QByteArray& data) override;
    virtual void disconnect() override;
    virtual void onReadyRead() override;
    virtual void processData(const QByteArray& data) override;
private:
    void onErrorOccured(QSerialPort::SerialPortError newError);
protected:
    QSerialPort* mSerial = nullptr;
};

#endif // SERIALCOM_H
